package com.moss.cloud.base.biz.controller;

import com.moss.cloud.base.api.model.from.BaseFrom;
import com.moss.cloud.base.api.model.from.PositionCodeFrom;
import com.moss.cloud.base.api.model.param.PositionCodeParam;
import com.moss.cloud.base.biz.service.ISysPositionCodeService;
import com.moss.cloud.common.core.constant.ServiceList;
import com.moss.cloud.common.core.model.Result;
import com.moss.cloud.common.security.annotation.SysLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 职位代号管理前端控制器
 *
 * @author 瑾年
 * @date 2023年12月18日
 */
@RestController
@RequestMapping(ServiceList.BASE + "/positionCode")
public class SysPositionCodeController {
    private final ISysPositionCodeService sysPositionCodeService;

    public SysPositionCodeController(ISysPositionCodeService sysPositionCodeService) {
        this.sysPositionCodeService = sysPositionCodeService;
    }

    /**
     * 职位代号分页数据
     *
     * @param positionCodeParam
     * @return
     */
    @PostMapping("/positionCodePage")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "查询职位代号数据")
    public Result<?> positionCodeList(@RequestBody PositionCodeParam positionCodeParam){
        return Result.success(sysPositionCodeService.positionCodeList(positionCodeParam));
    }

    /**
     * 新增职位代号
     *
     * @param positionCodeFrom
     * @return
     */
    @PostMapping("/savePositionCode")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "新增职位代号")
    public Result<?> savePositionCode(@RequestBody @Validated PositionCodeFrom positionCodeFrom){
        return Result.success(sysPositionCodeService.savePositionCode(positionCodeFrom));
    }

    /**
     * 更新职位代号
     *
     * @param positionCodeFrom
     * @return
     */
    @PostMapping("/updatePositionCode")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "更新职位代号")
    public Result<?> updatePositionCode(@RequestBody @Validated PositionCodeFrom positionCodeFrom){
        return Result.success(sysPositionCodeService.updatePositionCode(positionCodeFrom));
    }

    /**
     * 删除职位代号
     *
     * @param baseFrom
     * @return
     */
    @PostMapping("/removePositionCode")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "删除职位代号")
    public Result<?> removePositionCode(@RequestBody @Validated BaseFrom baseFrom){
        return Result.success(sysPositionCodeService.removePositionCode(baseFrom));
    }
}
